<?php

/**
 * List of all categories
 */

class menuComponents extends myComponents
{
  public function executeRender()
  {
    $this->categories = new ProductGroup;
    $this->products   = new Product;
    
    // Get all the categories
    $this->categories = $this->categories->getAll($this->getRoute()->getObject(), $this->getUser());
    $this->activeCat  = $this->getRoute()->getCategoryObject() ? $this->getRoute()->getCategoryObject()->getId() : false;
    
    // Get all products associated with the selected category
    if($this->getRoute()->getCategoryObject()) {
     $this->products = $this->products->getProducts($this->getRoute()->getCategoryObject()->getId());
    }
    
    if($this->getRoute()->getProductObject()) {
      $this->productActive = $this->getRoute()->getProductObject()->getId();
    } else $this->productActive = false;
    
    //echo '<pre>';
    //print_r($this->categories->toArray()); exit;
  }
};